capture log close
capture noisily log using "R:\Zentrale\ZB-S\Daten_FDSZ_Gastforscher\1_gafo\2016_0133\Table 6.log", replace
capture noisily log using "Table 6.log", replace

**** Load data in Stata
clear all
set more off
set maxvar 5000

capture noisily use "R:\Zentrale\ZB-S\Daten_FDSZ_Gastforscher\1_gafo\2016_0133\data\Bundesbank Discussion Paper\final_sample_03032023.dta", clear
capture noisily use "final_sample_03032023_pseudo.dta", clear


/* Deutsche Bundesbank checks that our results respect all confidentiality
   rules: If we wish to disclose a regression coefficient that identifies a 
   subset of banks, then this subset must contain a minimum number of banks 
   to comply with confidentiality rules. In regressions, this rule applies to 
   categorical regressors (including interacted ones). 

   The Bundesbank uses a self-written command to check compliance with the 
   confidentiality rules. This command does not always execute for 
   higher interactions (especially when the lower-level base effects are 
   absorbed by some FEs). For this reason, we generate a new variable 
   for each interaction term separately: */ 

gen DEU_AbrImp_AbrNImp_1 = 0
replace DEU_AbrImp_AbrNImp_1 = 1 if DEU_AbrImp_AbrNImp==1
gen DEU_AbrImp_AbrNImp_2 = 0
replace DEU_AbrImp_AbrNImp_2 = 1 if DEU_AbrImp_AbrNImp==2

gen sanctions_1_DEU_AbrImp_AbrNImp = sanctions * DEU_AbrImp_AbrNImp_1
gen sanctions_2_DEU_AbrImp_AbrNImp = sanctions * DEU_AbrImp_AbrNImp_2

gen FImp_FnImp_nFImp_nFnImp_1 = 0
replace FImp_FnImp_nFImp_nFnImp_1 = 1 if FImp_FnImp_nFImp_nFnImp==1
gen FImp_FnImp_nFImp_nFnImp_2 = 0
replace FImp_FnImp_nFImp_nFnImp_2 = 1 if FImp_FnImp_nFImp_nFnImp==2
gen FImp_FnImp_nFImp_nFnImp_3 = 0
replace FImp_FnImp_nFImp_nFnImp_3 = 1 if FImp_FnImp_nFImp_nFnImp==3

gen sanctions_1_FImp = sanctions * FImp_FnImp_nFImp_nFnImp_1
gen sanctions_2_FImp = sanctions * FImp_FnImp_nFImp_nFnImp_2
gen sanctions_3_FImp = sanctions * FImp_FnImp_nFImp_nFnImp_3



*** Regressions for Table 6
reghdfe lam100 c.sanctions c.sanctions#i.DEU_AbrImp_AbrNImp, absorb(systimeFE id) vce(cluster datum land CTRY)

reghdfe lam100 sanctions_1_DEU_AbrImp_AbrNImp sanctions_2_DEU_AbrImp_AbrNImp, absorb(systimeFE landtimeFE id) vce(cluster datum land CTRY)

reghdfe lam100 c.sanctions c.sanctions#i.FImp_FnImp_nFImp_nFnImp, absorb(systimeFE id) vce(cluster datum land CTRY)

reghdfe lam100 sanctions_1_FImp sanctions_2_FImp sanctions_3_FImp, absorb(systimeFE landtimeFE id) vce(cluster datum land CTRY)

log close
